home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / spoc88 / tbtasm / tbmax.asm < prev    next >
Assembly Source File  |  1988-06-14  |  795b  |  25 lines

  1. ;TBMAX.ASM  Routine to find max value in integer array
  2. CODE    SEGMENT
  3.     ASSUME    CS:CODE,DS:CODE
  4.     PUSH      BP             ;Save BP
  5.     MOV       BP,SP          ;Get stack address
  6. ;Get the arguments
  7.     LES       BX,[BP+06H]    ;Get addr of array count
  8.     MOV       CX,ES:[BX]     ;Put count in CX
  9.     LES       DI,[BP+0AH]    ;Get addr of first element
  10.     LES       BX,[BP+0EH]    ;Get addr of return value
  11. ;Find the max value
  12.     MOV       AX,ES:[DI]     ;Get first array element
  13. A:      CMP       AX,ES:[DI+2]   ;Compare present with next
  14.     JG        B
  15.     MOV       AX,ES:[DI+2]   ;Put new, larger value in AX
  16. B:      INC       DI
  17.     INC       DI
  18.     LOOP      A
  19.     MOV       ES:[BX],AX     ;Store max value
  20. ;Clean up and leave
  21. QUIT:   POP       BP             ;Restore BP
  22. CODE    ENDS
  23.     END
  24.  
  25.